package modelTest.model;

import java.util.Observable;

public class Ship {

	public static final int COLLISION_RAY = 80;		//Raggio di collisione da tenere uguale alla meta' della larghezza dello sprite.
	private Coordinate coordinate;
	private ShipMover shipMover;
	private int availableAmmo;
	
	
	public Ship(Coordinate coordinate, ShipMover moveEngine) {
		this.coordinate = coordinate;
		this.shipMover = moveEngine;
		this.availableAmmo = 5;
	}
	
	public Ship(Coordinate coordinate, ShipMover moveEngine, int initialAvailableAmmo) {
		this.coordinate = coordinate;
		this.shipMover = moveEngine;
		this.availableAmmo = initialAvailableAmmo;
	}
	
	
	public Coordinate getCoordinate() {
		return coordinate;
	}
	
	public void setAvailableAmmo(int availableAmmo) {
		if(availableAmmo > 0){
			this.availableAmmo = availableAmmo;
		}
	}
	
	
	
	/**
	 * Spostamento lungo l'asse X.
	 */
	public void moveXAxis( int direction ) {
		int newX = shipMover.calculateNewX( coordinate.getX(), direction);
		coordinate.setX(newX);
	}
	
	/**
	 * Spostamento lungo l'asse Y.
	 */
	public void moveYAxis(int direction) {
		int newY = shipMover.calculateNewY( coordinate.getY(), direction);
		coordinate.setX(newY);
	}
	
	/**
	 * Spostamento lungo l'asse Z.
	 */
	public void moveZAxis(int direction) {
		int newZ = shipMover.calculateNewZ( coordinate.getZ(), direction);
		coordinate.setZ(newZ);
	}
	
	
	public int getAviavailableAmmo() {
		return availableAmmo;
	}
}
